import java.util.*;

public class JIdea extends JContent{

	private ArrayList<JAttachment> attachments;
	private JState state;
	
	public JIdea(String title, String description) {
		super(title, description);
		attachments = new ArrayList<JAttachment>();
		state = new Draft();
	}
	
	public void evaluate(JValuation b){
		this.state.evaluate(b);
	}
	
	public void discuss(String text){
		state.discuss(text);
	}
	
	public void hold(){
		state.hold();
	}

	public void release(){
		state.release();
	}
	
	public void decline(){
		state.decline();
	}
	
	public String getCurrentDiscussion(){
		return state.getCurrentDiscussion();
	}

	public JValuation getValuation(){
		return state.getValuation();
	}
	
	public void addAttachment(JAttachment a){
		attachments.add(a);
	}
	
	public List<JAttachment> getAttachments(){
		return attachments;
	}
	
	public void removeAttachment(JAttachment attachment){
		attachments.remove(attachment);
	}
	
	public String toString(){
		return "Idea: " + super.getTitle() + "\n" + super.getDescription();
	}
	

private abstract class JState {

	private String currentDiscussion;
	private JValuation valuation;
	
	public void discuss(String text){
		this.currentDiscussion += text + "\n";
	}
	
	public void evaluate(JValuation b){
		this.valuation=b;
	}
	
	public void hold(){
		
	}

	public void release(){
		
	}
	
	public void decline(){
		
	}
	
	public String getCurrentDiscussion(){
		return currentDiscussion;
	}

	public JValuation getValuation(){
		return valuation;
	}
}
	
	public class Draft extends JState {
		
		public void hold(){
			state = new OpenDraft();
		}
		
		public void decline(){
			
		}
	}
		
	public class OpenDraft extends JState {
		
		public void hold(){
			state = new ApprovedIdea();
		}
		
		public void decline(){
			
		}
		
		public void discuss(String text){
			super.discuss(text);
		}
		
		public void evaluate(JValuation valuation){
			super.evaluate(valuation);
		}
	}
		
	public class ApprovedIdea extends JState {
		
		public void release(){
			
		}
	}
	
}
